package base.day18.exception;

import base.day18.array.Array;

public class Exception {
    public static void main(String[] args) {
        int[] array=null;

        try {
            printArr(array);
        }catch(NullPointerException e) {
            System.out.println("空指针异常");
        }

    }
    public static void printArr(int[] array){
        if (array==null){
//            throw new NullPointerException();
            System.out.println(1);
        }else {
            for (int i = 0; i < array.length; i++) {
                System.out.println(array[i]);
            }
        }
    }
}
